import Vue from "vue";
import Router from "vue-router";

import PROJECT_CONFIG from "../public/project.config";

Vue.use(Router);
// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};

const router = new Router({
  // mode: "history",
  base: process.env.BASE_URL,
  scrollBehavior() {
    return {
      x: 0,
      y: 0,
    };
  },
  routes: [{
    // MAIN LAYOUT ROUTES
    path: "",
    component: () => import("./layouts/main/Main.vue"),
    children: [{
      path: "/",
      name: "首页",
      // redirect:"/bridgeInformation/bridgeManagement",
      component: () =>
        import("@/views/homepage/HomePageTwo.vue"),
      meta: {
        // breadcrumb: [
        //   { title: "Home", url: "/" },
        //   { title: "" },
        //   { title: "数据监控", active: true }
        // ],
        pageTitle: "首页",
        rule: "editor"
      }
    },
      // {
      //   url: "/healthMonitor/statistical",
      //   name: "统计分析"
      // },
      // 监测报表
      {
        path: "/reportForm",
        name: "监测报表",
        component: () =>
          import("@/views/reportForm/reportForm.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "监测报表"
            },
            {
              title: "监测报表",
              active: true
            }
          ],
          pageTitle: "监测报表",
          rule: "editor"
        }
      },
      //Statistical
      {
        path: "/healthMonitor/statistical",
        name: "健康监测",
        component: () =>
          import("@/views/healthMonitor/statistical/statistical.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "健康监测"
            },
            {
              title: "统计分析",
              active: true
            }
          ],
          pageTitle: "统计分析",
          rule: "editor"
        }
      },
      // AllMonitor
      {
        path: "/healthMonitor/allMonitor",
        name: "健康监测",
        component: () =>
          import("@/views/healthMonitor/allMonitor/AllMonitor.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "健康监测"
            },
            {
              title: "整体监测",
              active: true
            }
          ],
          pageTitle: "整体监测",
          rule: "editor"
        }
      },
      // OnlyMonitor
      {
        path: "/healthMonitor/onlyMonitor",
        name: "健康监测",
        component: () =>
          import("@/views/healthMonitor/onlyMonitor/OnlyMonitor.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "健康监测"
            },
            {
              title: "单桥展示",
              active: true
            }
          ],
          pageTitle: "单桥展示",
          rule: "editor"
        }
      },
      //RealMonitor
      {
        path: "/healthMonitor/RealMonitor",
        name: "健康监测",
        component: () =>
          import("@/views/healthMonitor/realMonitor/RealMonitor.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "健康监测"
            },
            {
              title: "实时监测",
              active: true
            }
          ],
          pageTitle: "实时监测",
          rule: "editor"
        }
      },
      //RealLoad
      {
        path: "/healthMonitor/RealLoad",
        name: "健康监测",
        component: () =>
          import("@/views/healthMonitor/realLoad/RealLoad.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "健康监测"
            },
            {
              title: "实时荷载",
              active: true
            }
          ],
          pageTitle: "实时荷载",
          rule: "editor"
        }
      },
      //WarningList
      {
        path: "/healthMonitor/WarningList",
        name: "健康监测",
        component: () =>
          import("@/views/healthMonitor/warningList/WarningList.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "健康监测"
            },
            {
              title: "报警列表",
              active: true
            }
          ],
          pageTitle: "报警列表",
          rule: "editor"
        }
      },

      //桥梁信息
      /*南通桥梁新增*/
      {
        path: "/bridgeInformation/bridgeList",
        name: '桥梁列表',
        component: () => import("@/views/bridgeInformation/bridgeList.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "桥梁信息"
            },
            {
              title: "桥梁列表",
              active: true
            }
          ],
          pageTitle: "桥梁列表",
          rule: "editor"
        }
      },
      {
        path: "/bridgeInformation/recordManage",
        name: '档案管理',
        component: () => import("@/views/bridgeInformation/recordManage.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "桥梁信息"
            },
            {
              title: "档案管理",
              active: true
            }
          ],
          pageTitle: "档案管理",
          rule: "editor"
        }
      },
      {
        path: "/bridgeInformation/knowledgeStock",
        name: '知识库',
        component: () => import("@/views/bridgeInformation/knowledgeStock.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "桥梁信息"
            },
            {
              title: "知识库",
              active: true
            }
          ],
          pageTitle: "知识库",
          rule: "editor"
        }
      },
      {
        path: "/bridgeInformation/bridgeEvent",
        name: '桥梁大事记',
        component: () => import("@/views/bridgeInformation/bridgeEvent.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "桥梁信息"
            },
            {
              title: "桥梁大事记",
              active: true
            }
          ],
          pageTitle: "桥梁大事记",
          rule: "editor"
        }
      },



      {
        path: "/bridgeInformation/bridgeManagement",
        name: '桥梁管理',
        component: () => import("@/views/bridgeInformation/bridgeManagement.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "桥梁信息"
            },
            {
              title: "桥梁管理",
              active: true
            }
          ],
          pageTitle: "桥梁管理",
          rule: "editor"
        }
      },
      {
        path: "/bridgeInformation/modelManagement",
        name: '桥梁管理',
        component: () => import("@/views/bridgeInformation/modelManagement.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "桥梁信息"
            },
            {
              title: "模型管理",
              active: true
            }
          ],
          pageTitle: "模型管理",
          rule: "editor",
          parent: ['/bridgeInformation/bridgeManagement']
        }
      },
      {
        path: "/bridgeInformation/bridgeDetail",
        name: '桥梁管理',
        component: () => import("@/views/bridgeInformation/bridgeDetail.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "桥梁信息"
            },
            {
              title: "桥梁管理详情",
              active: true
            }
          ],
          pageTitle: "桥梁管理详情",
          rule: "editor",
          parent: ['/bridgeInformation/bridgeManagement']
        }
      },

        /*{
          path: "/bridgeInformation/archivesManagement",
          component: () => import("@/views/bridgeInformation/archivesManagement.vue"),
          meta: {
            breadcrumb: [{
                title: "Home",
                url: "/"
              },
              {
                title: "桥梁信息"
              },
              {
                title: "档案管理",
                active: true
              }
            ],
            pageTitle: "档案管理",
            rule: "editor"
          }
        },*/
      /*     {
             path: "/bridgeInformation/mearsuringPointSetting",
             component: () => import("@/views/bridgeInformation/mearsuringPointSetting.vue"),
             meta: {
               breadcrumb: [{
                   title: "Home",
                   url: "/"
                 },
                 {
                   title: "桥梁信息"
                 },
                 {
                   title: "测点管理",
                   active: true
                 }
               ],
               pageTitle: "测点管理",
               rule: "editor"
             }
           },*/
      {
        path: "/bridgeInformation/sectionManagement",
        component: () => import("@/views/bridgeInformation/monitoringType.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "桥梁信息"
            },
            {
              title: "监测类型",
              active: true
            }
          ],
          pageTitle: "监测类型",
          rule: "editor"
        }
      },
      {
        path: "/bridgeInformation/equipmentManagement",
        component: () => import("@/views/bridgeInformation/equipmentManagement.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "桥梁信息"
            },
            {
              title: "设备管理",
              active: true
            }
          ],
          pageTitle: "设备管理",
          rule: "editor"
        }
      },
      /*        {
                path: "/bridgeInformation/bridgeData",
                component: () => import("@/views/bridgeInformation/bridgeData.vue"),
                meta: {
                  breadcrumb: [{
                      title: "Home",
                      url: "/"
                    },
                    {
                      title: "桥梁信息"
                    },
                    {
                      title: "数据分类",
                      active: true
                    }
                  ],
                  pageTitle: "数据分类",
                  rule: "editor"
                }
              },*/
      {
        path: "/bridgeInformation/bridgeInfo",
        component: () => import("@/views/bridgeInformation/bridgeInfo.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "桥梁信息"
            },
            {
              title: "一桥一档",
              active: true
            }
          ],
          pageTitle: "一桥一档",
          rule: "editor"
        }
      },

      //巡检管理
      /*        {
                path: "/inspection/inspTmpl",
                component: () => import("@/views/inspection/inspTmpl.vue"),
                meta: {
                  breadcrumb: [{
                      title: "Home",
                      url: "/"
                    },
                    {
                      title: "巡检管理"
                    },
                    {
                      title: "巡检模板",
                      active: true
                    }
                  ],
                  pageTitle: "巡检模板",
                  rule: "editor"
                }
              },*/
      /*       {
               path: "/inspection/inspPlan",
               component: () => import("@/views/inspection/inspPlan.vue"),
               meta: {
                 breadcrumb: [{
                     title: "Home",
                     url: "/"
                   },
                   {
                     title: "巡检管理"
                   },
                   {
                     title: "巡检计划",
                     active: true
                   }
                 ],
                 pageTitle: "巡检计划",
                 rule: "editor"
               }
             },*/
      /*        {
                path: "/inspection/inspTask",
                component: () => import("@/views/inspection/inspTask.vue"),
                meta: {
                  breadcrumb: [{
                      title: "Home",
                      url: "/"
                    },
                    {
                      title: "巡检管理"
                    },
                    {
                      title: "巡检任务",
                      active: true
                    }
                  ],
                  pageTitle: "巡检任务",
                  rule: "editor"
                }
              },*/
      /*        {
                path: "/inspection/inspHistory",
                component: () => import("@/views/inspection/inspHistory.vue"),
                meta: {
                  breadcrumb: [{
                      title: "Home",
                      url: "/"
                    },
                    {
                      title: "巡检管理"
                    },
                    {
                      title: "巡检记录",
                      active: true
                    }
                  ],
                  pageTitle: "巡检记录",
                  rule: "editor"
                }
              },*/
      /*        {
                path: "/inspection/inspTotal",
                component: () => import("@/views/inspection/inspTotal.vue"),
                meta: {
                  breadcrumb: [{
                      title: "Home",
                      url: "/"
                    },
                    {
                      title: "巡检管理"
                    },
                    {
                      title: "巡检统计",
                      active: true
                    }
                  ],
                  pageTitle: "巡检统计",
                  rule: "editor"
                }
              },*/
      //4.6日新加的
      {
        path: "/inspection/inspManage",
        component: () => import("@/views/inspection/inspManage.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "巡检管理"
            },
            {
              title: "出勤管理",
              active: true
            }
          ],
          pageTitle: "出勤管理",
          rule: "editor"
        }
      },
      //定期检查
      {
        path: "/inspection/regularInspection",
        component: () => import("@/views/inspection/regularInspection.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "巡检管理"
            },
            {
              title: "定期检查",
              active: true
            }
          ],
          pageTitle: "定期检查",
          rule: "editor"
        }
      },
      //巡检计划
      {
        path: "/inspection/inspectionPlan",
        component: () => import("@/views/inspection/inspectionPlan.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "巡检管理"
            },
            {
              title: "巡检计划",
              active: true
            }
          ],
          pageTitle: "巡检计划",
          rule: "editor"
        }
      },
      //南通巡检任务
      {
        path: "/inspection/inspectionTask",
        component: () => import("@/views/inspection/inspectionTask.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "日常巡检"
            },
            {
              title: "巡检任务",
              active: true
            }
          ],
          pageTitle: "巡检任务",
          rule: "editor"
        }
      },
      //问题上报
      {
        path: "/inspection/problemReport",
        component: () => import("@/views/inspection/problemReport.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "日常巡检"
            },
            {
              title: "问题上报",
              active: true
            }
          ],
          pageTitle: "问题上报",
          rule: "editor"
        }
      },

      /* 4.25添加统计分析*/
      {
        path: "/statisticAnalysis/evaluate",
        component: () => import("@/views/statisticAnalysis/evaluate/evaluate.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "统计分析"
            },
            {
              title: "管养考评",
              active: true
            }
          ],
          pageTitle: "管养考评",
          rule: "editor"
        }
      },
      {
        path: "/statisticAnalysis/bigData",
        component: () => import("@/views/statisticAnalysis/bigData/bigData.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "统计分析"
            },
            {
              title: "管养大数据",
              active: true
            }
          ],
          pageTitle: "管养大数据",
          rule: "editor"
        }
      },

      /*5.7添加桥梁评定*/
      {
        path: "/bridgeJudge/manage",
        component: () => import("@/views/bridgeJudge/manage/manage.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "桥梁评定"
            },
            {
              title: "桥梁结构管理",
              active: true
            }
          ],
          pageTitle: "桥梁结构管理",
          rule: "editor"
        }
      },
      {
        path: "/bridgeJudge/judge",
        component: () => import("@/views/bridgeJudge/judge/judge.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "桥梁评定"
            },
            {
              title: "桥梁评定",
              active: true
            }
          ],
          pageTitle: "桥梁评定",
          rule: "editor"
        }
      },

      /*5.11添加定期检查*/
      {
        path: "/regularInspect/regularTask",
        component: () => import("@/views/regularInspect/regularTask"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "定期检查"
            },
            {
              title: "定检任务",
              active: true
            }
          ],
          pageTitle: "定检任务",
          rule: "editor"
        }
      },
      {
        path: "/regularInspect/regularRecord",
        component: () => import("@/views/regularInspect/regularRecord"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "定期检查"
            },
            {
              title: "定检记录",
              active: true
            }
          ],
          pageTitle: "定检记录",
          rule: "editor"
        }
      },

      //养护管理
      /*{
        path: "/curing/maintain",
        component: () => import("@/views/curing/maintain/maintain.vue"),
        meta: {
          breadcrumb: [{
              title: "Home",
              url: "/"
            },
            {
              title: "养护管理"
            },
            {
              title: "现场处理",
              active: true
            }
          ],
          pageTitle: "现场处理",
          rule: "editor"
        }
      },*/
      /*{
        path: "/curing/record",
        component: () => import("@/views/curing/record/record.vue"),
        meta: {
          breadcrumb: [{
              title: "Home",
              url: "/"
            },
            {
              title: "养护管理"
            },
            {
              title: "养护记录",
              active: true
            }
          ],
          pageTitle: "养护记录",
          rule: "editor"
        }
      },*/
      /* {
         path: "/curing/plan",
         component: () => import("@/views/curing/plan/plan.vue"),
         meta: {
           breadcrumb: [{
               title: "Home",
               url: "/"
             },
             {
               title: "养护管理"
             },
             {
               title: "养护计划",
               active: true
             }
           ],
           pageTitle: "养护计划",
           rule: "editor"
         }
       },*/
      /* {
         path: "/curing/addTask",
         component: () => import("@/views/curing/task/addTask.vue"),
         meta: {
           breadcrumb: [{
               title: "Home",
               url: "/"
             },
             {
               title: "养护管理"
             },
             {
               title: "养护任务"
             },
             {
               title: "新建任务",
               active: true
             }
           ],
           pageTitle: "养护任务",
           rule: "editor",
           parent: ["/curing/task"]
         }
       },*/
      /*  {
          path: "/curing/task",
          component: () => import("@/views/curing/task/task.vue"),
          meta: {
            breadcrumb: [{
                title: "Home",
                url: "/"
              },
              {
                title: "养护管理"
              },
              {
                title: "养护任务",
                active: true
              }
            ],
            pageTitle: "养护任务",
            rule: "editor"
          }
        },*/
      /*  {
          path: "/curing/total",
          component: () => import("@/views/curing/total/total.vue"),
          meta: {
            breadcrumb: [{
                title: "Home",
                url: "/"
              },
              {
                title: "养护管理"
              },
              {
                title: "养护统计",
                active: true
              }
            ],
            pageTitle: "养护统计",
            rule: "editor"
          }
        },*/
      /*4.28添加*/
      {
        path: "/curing/curingTask",
        component: () => import("@/views/curing/curingTask/curingTask.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "养护维修"
            },
            {
              title: "养护任务单",
              active: true
            }
          ],
          pageTitle: "养护任务单",
          rule: "editor"
        }
      },
      {
        path: "/curing/curingStatistics",
        component: () => import("@/views/curing/curingStatistics/curingStatistics.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "养护维修"
            },
            {
              title: "南通养护统计",
              active: true
            }
          ],
          pageTitle: "南通养护统计",
          rule: "editor"
        }
      },
      {
        path: "/curing/maintenance",
        component: () => import("@/views/curing/maintenance/maintenance.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "养护维修"
            },
            {
              title: "大中修",
              active: true
            }
          ],
          pageTitle: "大中修",
          rule: "editor"
        }
      },


      /*        //人员管理
              {
                path: "/personManage/PersonManage",
                component: () => import("@/views/personManage/PersonManage.vue"),
                meta: {
                  breadcrumb: [{
                      title: "Home",
                      url: "/"
                    },
                    {
                      title: "人员管理"
                    },
                    {
                      title: "人员管理",
                      active: true
                    }
                  ],
                  pageTitle: "人员管理",
                  rule: "editor"
                }
              },*/
      //知识库
      {
        path: "/knowledgeBase/Structure",
        component: () => import("@/views/knowledgeBase/Structure.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "知识库"
            },
            {
              title: "结构与病害",
              active: true
            }
          ],
          pageTitle: "结构与病害",
          rule: "editor"
        }
      },
      {
        path: "/knowledgeBase/history",
        component: () => import("@/views/knowledgeBase/history.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "知识库"
            },
            {
              title: "小修保养",
              active: true
            }
          ],
          pageTitle: "小修保养",
          rule: "editor"
        }
      },
      //统计分析
      {
        path: "/statisticAlanalysis/environmentAlanalysis",
        component: () => import("@/views/statisticAlanalysis/environmentAlanalysis.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "统计分析"
            },
            {
              title: "环境分析",
              active: true
            }
          ],
          pageTitle: "环境分析",
          rule: "editor"
        }
      },
      {
        path: "/statisticAlanalysis/structureTemperature",
        component: () => import("@/views/statisticAlanalysis/structureTemperature.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "统计分析"
            },
            {
              title: "结构温度分析",
              active: true
            }
          ],
          pageTitle: "结构温度分析",
          rule: "editor"
        }
      },
      {
        path: "/statisticAlanalysis/stressAmplitude",
        component: () => import("@/views/statisticAlanalysis/stressAmplitude.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "统计分析"
            },
            {
              title: "应力幅值分析",
              active: true
            }
          ],
          pageTitle: "应力幅值分析",
          rule: "editor"
        }
      },
      {
        path: "/statisticAlanalysis/displacementTrend",
        component: () => import("@/views/statisticAlanalysis/displacementTrend.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "统计分析"
            },
            {
              title: "位移趋势分析",
              active: true
            }
          ],
          pageTitle: "位移趋势分析",
          rule: "editor"
        }
      },
      //10.20添加
      {
        path: "/statisticAlanalysis/deflectionAnalysis",
        component: () => import("@/views/statisticAlanalysis/deflectionAnalysis.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "统计分析"
            },
            {
              title: "挠度分析",
              active: true
            }
          ],
          pageTitle: "挠度分析",
          rule: "editor"
        }
      },
      {
        path: "/statisticAlanalysis/inclinationAnalysis",
        component: () => import("@/views/statisticAlanalysis/angleAnalysis.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "统计分析"
            },
            {
              title: "倾角分析",
              active: true
            }
          ],
          pageTitle: "倾角分析",
          rule: "editor"
        }
      },
      {
        path: "/statisticAlanalysis/accelerationAnalysis",
        component: () => import("@/views/statisticAlanalysis/accelerationAnalysis.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "统计分析"
            },
            {
              title: "加速度分析",
              active: true
            }
          ],
          pageTitle: "加速度分析",
          rule: "editor"
        }
      },
      {
        path: "/statisticAlanalysis/cableAnalysis",
        component: () => import("@/views/statisticAlanalysis/cableAnalysis.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "统计分析"
            },
            {
              title: "索力分析",
              active: true
            }
          ],
          pageTitle: "索力分析",
          rule: "editor"
        }
      },


      //权限管理
      {
        path: "/system-manage/access-control/site-manage/SiteManage",
        name: "SiteManage",
        component: () =>
          import("@/views/access-control/site-manage/SiteManage"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "权限管理"
            },
            {
              title: "桥梁管理",
              active: true
            }
          ],
          pageTitle: "桥梁管理",
          rule: "editor"
        }
      },
      {
        path: "system-manage/access-control/resource-manage/resource",
        name: "resourceManageResource",
        component: () =>
          import("@/views/access-control/resource-manage/resource.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "权限管理"
            },
            {
              title: "资源管理",
              active: true
            }
          ],
          pageTitle: "资源管理",
          rule: "editor"
        }
      },
      {
        path: "system-manage/access-control/department-manage/department",
        name: "departmentManageDepartment",
        component: () =>
          import("@/views/access-control/department-manage/department.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "权限管理"
            },
            {
              title: "部门管理",
              active: true
            }
          ],
          pageTitle: "部门管理",
          rule: "editor"
        }
      },
      //role
      {
        path: "system-manage/access-control/role-manage/role",
        name: "role",
        component: () =>
          import("@/views/access-control/role-manage/role.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "权限管理"
            },
            {
              title: "角色管理",
              active: true
            }
          ],
          pageTitle: "角色管理",
          rule: "editor"
        }
      },
      {
        path: "system-manage/access-control/user-group-manage/UserGroup",
        name: "userGroup",
        component: () =>
          import("@/views/access-control/user-group-manage/UserGroup.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "系统管理"
            },
            {
              title: "用户组管理",
              active: true
            }
          ],
          pageTitle: "用户组管理",
          rule: "editor"
        }
      },
      {
        path: "system-manage/access-control/views-manage/Views",
        name: "views",
        component: () =>
          import("@/views/access-control/views-manage/Views.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "权限管理"
            },
            {
              title: "视图管理",
              active: true
            }
          ],
          pageTitle: "视图管理",
          rule: "editor"
        }
      },
      {
        path: "system-manage/access-control/user-manage/User",
        name: "user",
        component: () =>
          import("@/views/access-control/user-manage/User.vue"),
        meta: {
          breadcrumb: [{
            title: "Home",
            url: "/"
          },
            {
              title: "权限管理"
            },
            {
              title: "用户管理",
              active: true
            }
          ],
          pageTitle: "用户管理",
          rule: "editor"
        }
      },
    ]
  },

    // 此处设置全路由  login  404  等页面
    {
      path: "",
      component: () => import("@/layouts/full-page/FullPage.vue"),
      children: [{
        path: "/pages/login",
        name: "pageLogin",
        component: () => import("@/views/pages/Login.vue"),
        meta: {
          rule: "editor"
        }
      },
        {
          path: "/pages/error-404",
          name: "pageError404",
          component: () => import("@/views/pages/Error404.vue"),
          meta: {
            rule: "editor"
          }
        },
      ]
    },
    {
      path: "*",
      redirect: "/pages/error-404"
    }
  ]
});

router.afterEach(() => {
  // 移除 loading
  const appLoading = document.getElementById("loading-bg");
  if (appLoading) {
    appLoading.style.display = "none";
  }
  document.title = PROJECT_CONFIG.projectName;
});

router.beforeEach((to, from, next) => {
  // console.log("那个页面", to.path);
  if (to.name === "pageLogin") {
    //如果是登录页，则跳过验证
    next(); //必不可少
    return; //以下的代码不执行
  }

  if (!localStorage.getItem("token")) {
    next({
      name: "pageLogin",
    }); //如果未登录，则跳转到登录页
  } else {
    if (to.path == "/") {
      next();
      return;
    }
    let view = "";
    view = JSON.parse(localStorage.getItem("viewData"))[
      localStorage.getItem("viewIndex") || 0
    ].viewConfigDTO.menuGroups[1].submenu;

    // console.log(view)
    let i = -1;
    i = view.findIndex(d => {
      return d.url == to.path;
    });
    let j = -1;
    let k = -1;
    view.forEach(item => {
      if (item.submenu) {
        if (item.submenu.findIndex(d => d.url == to.path) >= 0) j = 0;
        item.submenu.forEach(items => {
          if (items.submenu) {
            if (items.submenu.findIndex(d => d.url == to.path) >= 0) k = 0;
          }
        });
      }
    });

    // console.log(i,'i',j,'j')
    // if(i>=0 || j>=0 || k>=0){
    //   next()
    // }else{
    //   next({
    //   name: "首页"
    //   });
    // }
    next();
  }
});

export default router;
